import React from 'react'
import $ from 'jquery'
import dispatcher from 'lib/dispatcher'
import Modal from './Modal.jsx'

export function ConfirmGreen (contents) {

  var confirmEl = ConfirmView.mount({contents:contents});
  return confirmEl.dtd

}

class ConfirmView extends Modal {
  constructor(props){
    super(props)
    this.confirmTrueAction = this.confirmTrueAction.bind(this)
  }
  componentDidMount(){
    super.componentDidMount()
    this.dtd = $.Deferred()
  }
  componentWillUnmount(){
    super.componentWillUnmount()
    this.dtd.reject()
  }
  confirmTrueAction(){
    this.dtd.resolve();
    this.close();
  }
  renderHeader(){
    return (
      <h4>提醒消息</h4>
    )
  }

  renderBody(){
    return (
       <h4>{this.props.contents}</h4>
    )
  }

  renderFooter(){
    return (
      <div>
        <button className="btn-green"
          onClick={this.confirmTrueAction}
          type="button">
          确认
        </button>
      </div>
    )
  }

}
